﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
using com.pro2e.console.service.auth.vo;
using com.pro2e.web.util;
using com.pro2e.console.service.auth;
using com.pro2e.web.util.page;
using com.pro2e.web.config;
using sexhealth.console.service.common;

public partial class activityAdmin_top : System.Web.UI.Page
{
    AuthService authService = new AuthService();
    SessionHelper sHelper = new SessionHelper();
    ConfigHelper configHelper = new ConfigHelper();

    protected void Page_Load(object sender, EventArgs e)
    {
      
        LoginUser user = sHelper.LoginUser;

        if (user != null)
        {
            user = authService.LoadLoginUser(user.UserId);

            IList<LoginRole> roleList = user.BelongRoles;

            List<string> roleStr = new List<string>();

            if (roleList != null && roleList.Count > 0)
            {
                foreach (LoginRole role in roleList)
                {
                    roleStr.Add(role.RoleName);
                }
            }
            lblUserId.Text = user.UserId;
            lblRole.Text = String.Join(",", roleStr.ToArray());
            lblDate.Text = DateTime.Today.Year - 1911 + "/" + DateTime.Today.Month.ToString("00") + "/" + DateTime.Today.Day.ToString("00");
        }
        else
        {
            Response.Redirect(UIHelper.LOGIN_PAGE_MANAGER, false);
            return;
        }
    }
 
    private void logout()
    {

        sHelper.LoginUser = null;
        Session.Clear();
        string url = string.Format("top.document.location.href='http://{0}/activityAdmin/index.aspx';", configHelper.Host);
        ScriptManager.RegisterClientScriptBlock(lblMsg, lblMsg.GetType(), "gotoJs", JavascriptUtil.WrapperScript(url), false);
        return;
    }
    protected void btnLogout_Click1(object sender, ImageClickEventArgs e)
    {
        logout();
    }
}
